#ifndef SCT_ENCODE_ENCODEINTERFACE_H
#define SCT_ENCODE_ENCODEINTERFACE_H

#include <stdint.h>

namespace sct
{

enum CodecType
{
	CT_H264 = 1,
	CT_AAC,
	CT_AMR,
};

enum PCMFormat {
	PCM_FMT_S16 = 1,
};

enum PCMChannel
{
	PCM_CH_STEREO = 1,
	PCM_CH_MONO,
};

class CEncodeParam
{
public:
	int bitrate;

	PCMFormat sample_fmt;
	PCMChannel channel_layout;
	int sample_rate;
	int sample_num_in_frame;

	int width;
	int height;
	int fps;
	int gopsize;
	int max_b_frames;
};

class CEncodeCallBack;
class CEncodeInterface
{
public:
	class CBlockInfo
	{
	public:
		int64_t pts;
	};

public:
	/**
	 * init the encode library
	 */
	static void initlib();
	/**
	 * create a encoder
	 *
	 * @param name must be 'encode'
	 */
	static CEncodeInterface* create(const char * name, const CodecType codecType);
	virtual ~CEncodeInterface() {}

	virtual void init(const CEncodeParam & param) {}
	/**
	 * encode one frame
	 *
	 * @param pts the unit is micro second
	 */
	virtual void encodeOneFrame(const int64_t pts, const void* buf, const int len) {}

	void addCallback(CEncodeCallBack * callback){mCallback = callback;}
	void delCallback(CEncodeCallBack * callback){mCallback = NULL;}

protected:
	CEncodeInterface(const CodecType codecType):mCallback(NULL), mCodecType(codecType) {}

protected:
	CEncodeCallBack* mCallback;
	CodecType mCodecType;
};

class CEncodeCallBack
{
public:
	virtual ~CEncodeCallBack(){}

	virtual void onGenData(CEncodeInterface * caller,
			const void* buf, const int len,
			const CEncodeInterface::CBlockInfo & info){}
};

}

#endif
